///////////////////////////////////////////////////////////////////////////////
//
//  SlideshowCreate.js   			version 1.0
//
//  This file is provided by First Floor and implements parts of the Slideshow.
//
//  See also http://www.firstfloorsoftware.com/Slideshow.
// 
//  Copyright (c) 2007 First Floor. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////

//Changed by Szunyi, SBPweb tech
// scene became global variable
var scene;
// introduced xmlprefix
var sceneSourceXmlPrefix = '';
//

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function createSlideshow(parentId, settings){
    if (!parentId){
        alert("Missing required parentId parameter");
        return;
    }
    if (!settings)settings = {};
    scene = new Slideshow.Scene();

    var auth = Sys.Services.AuthenticationService;
    var cookie = getCookie("username");
    //auth.set_Path("");
    //login(username, password, isPersistent, customInfo, redirectUrl, loginCompletedCallback, failedCallback, userContext)
    //var l = auth.login("host", "passw0rd", false, null, null, null, null, "User Context");
	
	Silverlight.createObjectEx({
		source: sceneSourceXmlPrefix + 'Scene.xml',
		parentElement: document.getElementById(parentId),
		id: parentId + 'SilverlightPlugIn',
		properties: {
			width: settings.width == undefined ? '400' : settings.width,
			height: settings.height == undefined ? '388' : settings.height,
			background: settings.pageBackground == undefined ? "White" : settings.pageBackground,
            isWindowless: 'false',
			version: '0.8'
		},
		events: {
		    onError: null,
			onLoad: Silverlight.createDelegate(scene, scene.handleLoad)
		},		
		context: settings 
	});
}

if (!window.Silverlight) 
	window.Silverlight = {};

Silverlight.createDelegate = function(instance, method) {
	return function() {
        return method.apply(instance, arguments);
    }
}